package Thread;

public class Demo15 {
    private  static  int count = 0;
    public static void main(String[] args) {
        Object locker1  = new Object();
        Object locker2 = new Object();
        Thread t1 = new Thread(()->{
            for (int i = 0; i < 50000; i++) {
                synchronized (locker1){
                    synchronized (locker2){
                        count++;
                    }
                }
            }
            System.out.println("t1 结束");
        });
        Thread t2 = new Thread(()->{
            for (int i = 0; i < 50000; i++) {
                synchronized (locker2){
                    synchronized (locker1){
                        count++;
                    }
                }
            }
            System.out.println("t2结束");
        });
        t1.start();
        t2.start();
    }
}
